package com.universal_library.weight;

import android.content.Context;
import android.text.TextUtils;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import com.universal_library.R;


/**
 * Created by solin on 2017/5/18.
 */

public class AppToast {
    private static long nextONlickTime;

    public static void showToast(Context context, String content1, String content2) {
        long current = System.currentTimeMillis();
        View view = LayoutInflater.from(context).inflate(R.layout.view_toast_app, null);
        TextView tv_content1 = (TextView) view.findViewById(R.id.tv_toast_content1);
        TextView tv_content2 = (TextView) view.findViewById(R.id.tv_toast_content2);
        if (TextUtils.isEmpty(content1))
            tv_content1.setVisibility(View.GONE);
        else
            tv_content1.setText(content1);
        if (TextUtils.isEmpty(content2))
            tv_content2.setVisibility(View.GONE);
        else
            tv_content2.setText(content2);
        Toast toast = new Toast(context);
        toast.setView(view);
        toast.setGravity(Gravity.CENTER, 0, -80);
        toast.setDuration(Toast.LENGTH_SHORT);
        nextONlickTime = current + Toast.LENGTH_SHORT;
        toast.show();
    }
}
